package com.xyht.sca_s.student_manage_system.modules.agreement.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xyht.sca_s.student_manage_system.modules.agreement.entity.SmsAgreementApplicationProcess;
import com.xyht.sca_s.student_manage_system.modules.agreement.mapper.SmsAgreementApplicationProcessMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ApplicationInit {
    @Autowired
    private SmsAgreementApplicationProcessMapper smsAgreementApplicationProcessMapper;

    private String[] departmentNameArray = {"项目发起单位","法务部","财务部", "后勤部",
            "秘书处", "分管副董事长", "董事长"};

    @Bean
    public void agreementApplicationInit() {
        List<SmsAgreementApplicationProcess> processList =
                smsAgreementApplicationProcessMapper.selectList(new QueryWrapper<>());
        if (processList == null || processList.size() < 1) {
            int sort = 1;
            for (String departmentName : departmentNameArray) {
                SmsAgreementApplicationProcess addProcess =
                        new SmsAgreementApplicationProcess();
                addProcess.setProcessName(departmentName);
                addProcess.setProcessIsUse(true);
                addProcess.setProcessIsStamp(false);
                addProcess.setProcessIsSign(true);
                addProcess.setProcessIsApplicationEdit(false);
                addProcess.setProcessSort(sort++);
                smsAgreementApplicationProcessMapper.insert(addProcess);
            }


        }
    }


}
